/***************************************************************************
 *   Copyright (C) 2007 by Eduardo Robles Elvira   *
 *   edulix@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 
#include <errno.h>
#include <QTimer>
#include <QDebug>
#include <QMetaType>
#include <QDomDocument>
#include <iostream>
#include <QModelIndex>
#include <QMutex>
#include <QItemSelectionModel>
#include <QSortFilterProxyModel>
#include <QVariant>
#include "konntrackwidget.h"
#include "eventsmodel.h"
#include "konntrackmodel.h"
#include "konntracksortfiltermodel.h"

using namespace std;

KonntrackWidget::KonntrackWidget(QWidget* parent, Qt::WFlags fl)
	: QWidget( parent, fl ), Ui::Form()
{
	KonntrackModel *km = new KonntrackModel(this);
	EventsModel *em = new EventsModel(this);
	
	konntracksProxy = new KonntrackSortFilterProxyModel;
	eventsProxy = new KonntrackSortFilterProxyModel;
	
	konntracksProxy->setSourceModel(km);
	eventsProxy->setSourceModel(em);
	konntracksProxy->setDynamicSortFilter(true);
	eventsProxy->setDynamicSortFilter(true);
	
	setupUi(this);
	
	conntracksView->setModel(konntracksProxy);
	eventsView->setModel(eventsProxy);
	
	km->setSelectionModel(conntracksView->selectionModel());
	
	connect(removeConntrackButton, SIGNAL(clicked()), km, SLOT(removeSelection()));
	connect(conntracksView, SIGNAL(removeSelection()), km, SLOT(removeSelection()));
	
	connect(clearEventsButton, SIGNAL(clicked()), em, SLOT(clearEvents()));
	connect(eventsView, SIGNAL(clearEvents()), em, SLOT(clearEvents()));
	
	conntracksView->setRootIsDecorated(false);
	conntracksView->setAlternatingRowColors(true);
	
	eventsView->setRootIsDecorated(false);
	eventsView->setAlternatingRowColors(true);
}

KonntrackWidget::~KonntrackWidget()
{
}


